/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hessingerbg.gui;

import java.awt.event.KeyEvent;
import java.util.HashMap;
import java.util.Vector;

/**
 *
 * @author MikeLaptop
 */
public class KeyVector extends Vector<String>{

    @Deprecated
    public static final HashMap<String, Integer> keyMap = keyMap();
    @Deprecated
    public static final HashMap<String, Integer> modMap = modMap();

    @Deprecated
    public static final Vector<String> keyvector = new Vector(keyMap().keySet());
    @Deprecated
    public static final Vector<String> modvector = new Vector(modMap().keySet());

    public static KeyVector getKeys()
    {
        KeyVector ret = new KeyVector();

        for(int x = 48; x < 59; x++ )
        {
            ret.add(String.valueOf((char)x));
        }

        for(int x = 65; x < 91; x++ )
        {
            ret.add(String.valueOf((char)x));
        }
        return ret;
    }

    public static int getKeyValue(String x)
    {
        return (int)(x.charAt(0));
    }

    public static KeyVector getModifiers()
    {
        KeyVector ret = new KeyVector();
        ret.add("NONE");
        ret.add("SHIFT");
        ret.add("CTRL");
        ret.add("ALT");
        return ret;
    }

    public static int getModifierValue(String x)
    {
        int ret = -1;
        if(x.equalsIgnoreCase("SHIFT"))
            ret = KeyEvent.VK_SHIFT;
        else if(x.equalsIgnoreCase("ALT"))
            ret = KeyEvent.VK_ALT;
        else if(x.equalsIgnoreCase("CTRL"))
            ret = KeyEvent.VK_CONTROL;
        System.out.println("Debug: getModifierValue(String x) = " + ret);
        return ret;
    }

    public static String getModifierSelection(int x)
    {
        String ret = "NONE";
        if(x == 16)
        {
            ret = "SHIFT";
        }
        if(x == 17)
        {
            ret = "CTRL";
        }
        if(x == 18)
        {
            ret = "ALT";
        }
        return ret;
    }
    /**
     * 1.00a
     * Replace by getKeys()
     * @return
     */
    @Deprecated
    private static HashMap<String, Integer> keyMap() {
        /*TODO Add function keys*/
        HashMap<String, Integer> map = new HashMap<String, Integer>();

        for(int x = 48; x < 59; x++ )
        {
            map.put(String.valueOf((char)x), x);
        }

        for(int x = 65; x < 91; x++ )
        {
            map.put(String.valueOf((char)x), x);
        }

        return map;
    }

   /**
     * 1.00a
     * Replace by getModifiers()
     * @return
     */
    @Deprecated
    private static HashMap<String, Integer> modMap() {
        HashMap<String, Integer> map = new HashMap<String, Integer>();
        map.put("NONE", new Integer(-1));
        map.put("SHIFT", new Integer(KeyEvent.VK_SHIFT));
        map.put("CTRL", new Integer(KeyEvent.VK_CONTROL));
        map.put("ALT", new Integer(KeyEvent.VK_ALT));

        return map;
    }
}